package com.qinglei.recoup.system.manager;

import com.qinglei.recoup.common.service.CacheService;
import com.qinglei.recoup.common.utils.RecoupUtil;
import com.qinglei.recoup.system.domain.DictBO;
import com.qinglei.recoup.system.service.DictService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DictManager {
    @Resource
    private CacheService cacheService;
    @Resource
    private DictService dictService;

    public DictBO getDictItem(String itemGroup, Long key){
        return RecoupUtil.selectCacheByTemplate(
                () -> this.cacheService.getDictItem(itemGroup, key),
                () -> this.dictService.getDictItem(itemGroup, key));
    }

    public List<DictBO> getDictItemList(String itemGroup){
        return RecoupUtil.selectCacheByTemplate(
                () -> this.cacheService.getDictItemList(itemGroup),
                () -> this.dictService.getDictItemList(itemGroup));
    }

}
